Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply postprocessors even if they don't need training #940

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Conversation

simonpcouch
Copy link
Contributor

Closes #939.

library(tidymodels)
library(tailor)

set.seed(121)
ad_split <- initial_split(ad_data, strata = Class)
ad_tr <- training(ad_split)
ad_te <- testing(ad_split)
ad_rs <- vfold_cv(ad_tr, repeats = 10, strata = Class)

rf_spec <- rand_forest() %>% set_mode("classification")

rf_bl_wflow <- 
  workflow(Class ~ ., rf_spec)

post_high <- tailor() %>% adjust_probability_threshold(0.99)
post_low  <- tailor() %>% adjust_probability_threshold(0.01)

high_wflow <- 
  rf_bl_wflow %>% 
  add_tailor(post_high)

low_wflow <- 
  rf_bl_wflow %>% 
  add_tailor(post_low)

cls_mtr <- metric_set(roc_auc, brier_class, sensitivity, specificity, j_index, mcc)

set.seed(1)
rf_bl_res <- rf_bl_wflow %>% fit_resamples(ad_rs, metrics = cls_mtr)

set.seed(1)
high_res <- high_wflow %>% fit_resamples(ad_rs, metrics = cls_mtr)

set.seed(1)
low_res <- low_wflow %>% fit_resamples(ad_rs, metrics = cls_mtr)

identical(collect_metrics(rf_bl_res), collect_metrics(low_res))
#> [1] FALSE
identical(collect_metrics(high_res), collect_metrics(low_res))
#> [1] FALSE

Created on 2024-09-18 with reprex v2.1.1

@simonpcouch simonpcouch requested a review from topepo September 18, 2024 14:38
@simonpcouch
Copy link
Contributor Author

Failures appear related to changes in other packages, so will go ahead and request review.

@topepo topepo merged commit 5737af7 into main Sep 18, 2024
11 checks passed
@topepo topepo deleted the post-939 branch September 18, 2024 19:58
Copy link

github-actions bot commented Oct 6, 2024

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apply postprocessor even if it doesn't require training
2 participants